import type { IFieldProps, IConfigProps } from '@/components/sofastui/AdvancedTable/interface'
import type { FormRule } from '@form-create/element-ui'

export const fields: IFieldProps[] = [
  {
    label: '标题',
    prop: 'title',
    import: true,
    export: true,
  },
  {
    label: '作者',
    prop: 'author',
    import: true,
    export: true,
  },
  {
    label: '关键字',
    prop: 'keyword',
    import: true,
    export: true,
  },
  {
    label: '类型',
    prop: 'type',
    width: 120,
    align: 'center',
    import: true,
    export: true,
    type: 'switch',
    isTag: true,
    filter: true,
    options: [
      {
        label: '普通公告',
        value: 1,
      },
      {
        label: '弹窗公告',
        value: 0,
      },
    ],
  },
  {
    label: '生效时间',
    prop: 'startTime',
    import: true,
    export: true,
  },
  {
    label: '失效时间',
    prop: 'endTime',
    import: true,
    export: true,
  },
  {
    label: '创建时间',
    prop: 'createdAt',
    import: true,
    export: true,
  },
]

export const config: IConfigProps = {
  name: 'sysNoteTable',
  rowKey: 'id',
  url: '/api/sys/note',
  selection: true,
  add: true,
  delete: true,
  expand: true,
  showIndex: true,
  import: true,
  export: true,
  search: true,
  advancedSearch: true,
  refresh: true,
  settings: true,
}

export const formRules: FormRule = [
  {
    type: 'input',
    field: 'title',
    title: '公告标题',
    $required: true,
    props: {
      placeholder: '请输入公告标题',
    },
    _fc_id: 'id_Fja7mc31xer3alc',
    name: 'title',
    display: true,
    hidden: false,
    _fc_drag_tag: 'input',
    col: {
      span: 24,
    },
  },
  {
    type: 'select',
    field: 'type',
    title: '公告类型',
    effect: {
      fetch: '',
    },
    value: 1,
    options: [
      {
        label: '普通公告',
        value: 1,
      },
      {
        label: '弹窗公告',
        value: 2,
      },
    ],
    $required: true,
    props: {
      clearable: true,
    },
    _fc_id: 'id_Fwh5mc35zbnbchc',
    name: 'type',
    display: true,
    hidden: false,
    _fc_drag_tag: 'select',
    col: {
      span: 12,
    },
  },
  {
    type: 'input',
    field: 'author',
    title: '作者',
    $required: false,
    props: {
      placeholder: '请输入作者',
    },
    _fc_id: 'id_Fja7mc22xer3alc',
    name: 'author',
    display: true,
    hidden: false,
    _fc_drag_tag: 'input',
    col: {
      span: 12,
    },
  },
  {
    type: 'input',
    field: 'keyword',
    title: '关键字',
    $required: false,
    props: {
      placeholder: '请输入关键字',
    },
    _fc_id: 'id_Fja7mc18xer3alc',
    name: 'keyword',
    display: true,
    hidden: false,
    _fc_drag_tag: 'input',
    col: {
      span: 24,
    },
  },
  {
    type: 'TinymceEditor',
    field: 'content',
    title: '公告内容',
    $required: true,
    props: {
      placeholder: '请输入公告内容',
      options: {
        height: 400,
      },
    },
    _fc_id: 'id_Fwn2mx22xuazaoc',
    name: 'content',
    display: true,
    hidden: false,
    _fc_drag_tag: 'TinymceEditor',
    col: {
      span: 24,
    },
  },
  {
    type: 'datePicker',
    field: 'startTime',
    title: '生效时间',
    $required: false,
    props: {
      type: 'datetime',
    },
    _fc_id: 'id_F1cumcgf4ucqarc',
    name: 'startTime',
    display: true,
    hidden: false,
    _fc_drag_tag: 'datePicker',
    col: {
      span: 12,
    },
    style: {
      width: '100%',
    },
  },
  {
    type: 'datePicker',
    field: 'endTime',
    title: '失效时间',
    $required: false,
    props: {
      type: 'datetime',
    },
    _fc_id: 'id_F2cumcgf4ucqarc',
    name: 'endTime',
    display: true,
    hidden: false,
    _fc_drag_tag: 'datePicker',
    col: {
      span: 12,
    },
    style: {
      width: '100%',
    },
  },
]
